package com.spm.librarianmanagersystem.controller;

import com.alibaba.fastjson.JSONObject;
import com.spm.librarianmanagersystem.service.UserInfoService;
import com.spm.librarianmanagersystem.utils.JsonResult;
import com.spm.librarianmanagersystem.utils.UserContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DashboardController {
    @Autowired
    private UserInfoService uis;

    @GetMapping("/api/admin/dashboard")
    public JsonResult<JSONObject> getAdminDashboardInfo(){
        return new JsonResult<>(uis.getAdminDashboardInfo());
    }

    @GetMapping("/api/dashboard")
    public JsonResult<JSONObject> getReaderDashboardInfo(){
        String currentUserId = UserContextHolder.getCurrentUserId();
        return new JsonResult<>(uis.getReaderDashboardInfo(currentUserId));
    }

}
